package com.ypy.context.utils;

import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

public class FileUtils {

	private static final String CLASS_FILE_SUFFIX = ".class";

	public static boolean isClassFile(@Nullable String url) {
		if (!StringUtils.hasText(url)) {
			return false;
		}
		if (url.endsWith(CLASS_FILE_SUFFIX))
			return true;
		return false;
	}

	public static String withoutClassSuffix(String url) {
		Assert.hasText(url,"url must not be null or empty");
		return url.replace(".class","");
	}

	//replace dots with backslash
	public static String replaceBackslashWithDots(String url) {
		Assert.hasText(url, "url must not be null or empty");
		return url.replaceAll("\\\\",".");
	}
}
